/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: javaseapp - Arr2
 * <p>Powered by webrx On 2021-08-04 09:32:54
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Arr2 {
    public static void main(String[] args) {
        //数组是固定长度，声明后不能调整大小
        int[] a = new int[]{1, 20, 300};
        System.out.println(a.length);//3
        System.out.println(a[2]);//300

        //a[3] = 6;  数组是固定长度，不能调整大小
        System.out.println(a.length);

        //遍历一
        for (var i : a) {
            System.out.println(i);
        }

        //遍历二
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

        //遍历三 倒序遍历
        for (int i = a.length - 1; i >= 0; i--) {
            System.out.println(a[i]);
        }

        //遍历四 java8 lambda 表达式遍历方式
        Arrays.stream(a).forEach(System.out::println);
    }
}
